# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/14 下午4:01
 @Author  : tgy
 
"""


# MyType=type('MyType',{supers}, locals)
class MyType(type):
    ...

    # new 方法是分配内存
    def __new__(cls, *args, **kwargs):
        ...
        print(cls)
        # __new__ 是一个静态方法，所以需要传递 cls
        per = super().__new__(cls, *args, **kwargs)
        return per

    # init 初始化分配内存的数据
    def __init__(cls, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def __call__(self, *args, **kwargs):
        ...
        obj = self.__new__(self)
        obj.__init__(*args, **kwargs)
        print(obj)
        return obj


# Person=MyType(class_name,supers,locals)
class Person(object, metaclass=MyType):
    ...

    def __init__(self, name, age):
        self.__name = name
        self.__age = age

    def __call__(self, *args, **kwargs):
        print(self)


if __name__ == '__main__':
    ...
    person = Person('lisi', 21)
    person()
    print(person)
